I have an object with an OLE item. In order to get all the content and then send it to a .NET app (rich textbox control), I use the DXL richTextWithOle(o."Object Text") function. Then, the RTF is properly set in my Rich Textbox control, and without doing any changes, this RTF is sent back to DOORS. Finally, I store the content again in my object through the DXL o."Object Text" = richText returningText, where returningText is the large string containing all the RTF content. Then, the problem is that in the DOORS list of objects, that OLE does not appear anymore. But if I do the same again (getting the Object Text, sending ...), my Rich Textbox control is able to paint the OLE item properly, so the OLE is not lost, but somehow it' not being shown in DOORS. I can see that the RTF is different. A) When I got it from the Object Text:
{\rtf1\ansi\ansicpg1252\deff0\deflang1036{\fonttbl{\f0\fnil\fcharset0 Tahoma;}}
{\*\generator Msftedit 5.41.21.2510;}
\viewkind4\uc1\pard\sa200\f0\fs20
{\pict\wmetafile8\picw17017\pich7624\picwgoal9360\pichgoal4200
010009000003d04204000000a742040000000400000......
B) When set in my Rich Textbox control:
{\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2{\fonttbl{\f0\fcharset0 Times New Roman;}
{\f2\fcharset0 Segoe UI;}{\f3\fcharset0 Tahoma;}}
{\colortbl\red0\green0\blue0;\red255\green255\blue255;}
\loch\hich\dbch\pard\plain\ltrpar\itap0
{\lang1033\fs20\f3\cf0 \cf0\ql{\f3 {\ltrch {\*\shppict{\pict\picwgoal9360\pichgoal4200\pngblip
89504e470d0a1a0a0000000d494844......
Both seems to work (if I copy/paste both in an external RTF file, OLE is properly shown), but the returning one does not display the OLEs in DOORS. I don't know if it's because of the DOORS RTF version or something related... BTW I'm using DOORS 9.4, .NET WPF RichTextBox control, and ASCII encoding (I tried with UTF8 as well).
Any ideas? Thanks a lot! Borja López - Thu Dec 12 05:13:13 EST 2013 |
Re: RTF OLE image not displayed After some researching, I noticed about the concept of the RTF Specification. For example, the WPF RichTextBox control supports the latest one (1.9 from MS Office 2007, http://www.microsoft.com/en-us/download/details.aspx?id=10725). Maybe this could be the reason, but I cannot find the RTF specification that the different DOORS version are using. |
Re: RTF OLE image not displayed Borja López - Fri Dec 13 03:39:30 EST 2013 After some researching, I noticed about the concept of the RTF Specification. For example, the WPF RichTextBox control supports the latest one (1.9 from MS Office 2007, http://www.microsoft.com/en-us/download/details.aspx?id=10725). Maybe this could be the reason, but I cannot find the RTF specification that the different DOORS version are using. Been there, done that ;-) The WPF richtext box is not compatible to the one used by DOORS. I experienced also troubles with displaying the content in a correct way, especially with the scaling of OLE objects. I ended up using a WindowsFormsHost a windows forms host embedding a System.Windows.Forms.RichTextBox item. But I had to go through some troubles getting scrolling and resizing behaviour correctly. I cannot post the source code here, since I do not have the IP rights. I can however give you more info, if necessary. Regards, Mathias |
Re: RTF OLE image not displayed Mathias Mamsch - Fri Dec 13 05:31:31 EST 2013 Been there, done that ;-) The WPF richtext box is not compatible to the one used by DOORS. I experienced also troubles with displaying the content in a correct way, especially with the scaling of OLE objects. I ended up using a WindowsFormsHost a windows forms host embedding a System.Windows.Forms.RichTextBox item. But I had to go through some troubles getting scrolling and resizing behaviour correctly. I cannot post the source code here, since I do not have the IP rights. I can however give you more info, if necessary. Regards, Mathias Thank you very much for your answer, Mathias. It's a pity because we are using some functionalities of the WPF RTB that cannot be achieved (AFAIK) with the Winforms one, such as using TextRanges and CaretPositions to display floating comboBoxes over the rtb. Do you know a way to keep using the WPF RTB visually, but somehow use the WinForms one for the backend? If not, what approach did you follow when facing this problem?
Thanks for your time. Regards, Borja. |
Re: RTF OLE image not displayed Borja López - Fri Dec 13 06:57:38 EST 2013 Thank you very much for your answer, Mathias. It's a pity because we are using some functionalities of the WPF RTB that cannot be achieved (AFAIK) with the Winforms one, such as using TextRanges and CaretPositions to display floating comboBoxes over the rtb. Do you know a way to keep using the WPF RTB visually, but somehow use the WinForms one for the backend? If not, what approach did you follow when facing this problem?
Thanks for your time. Regards, Borja. I could not spend more than two days on that problem at that time, so I did not try very long to get things running on the WPF variant. I read a lot of complaints on the net about the WPF richtext box not being compatible to the non-WPF one and from what I read I think I remember that this was considered a bug to be fixed. However I am not sure how this discussion went and if there might be a fix available. Maybe we are even not talking about the same issue, because you are saying that your richText boxes are showing the DOORS content correctly? My problem was, that the WPF box did not even show the content correctly. My luck was, that I did not even need to go into the 'edit' problem (I only needed to display the information). To do what you describe with the Winforms will be no fun, although possible with a lot of effort... The WinForms has functions for measuring the richText parts, so you could go with trying to put your Winforms comboboxes at the right position, but this would be probably just as bad as having to write your own richtext editor. So if the WPF RTB is showing the stuff alright now, the other thing you could try is dissect the richText to reformat any OLE objects so that they are compatible to DOORS again. Maybe you can work with the 'removeUnlistedRichText' function to make the generated RTF more compatible before writing it to DOORS. Or maybe you find something like an RTF 1.x to RTF 1.0 downgrade library that will create more compatible richtext for DOORS. From what I see DOORS could ignore the OLE because of the {\*\shppict ... } tag. Did you try to manually remove it and see if the OLE object reappears? Regards, Mathias |
Re: RTF OLE image not displayed Mathias Mamsch - Fri Dec 13 07:23:06 EST 2013 I could not spend more than two days on that problem at that time, so I did not try very long to get things running on the WPF variant. I read a lot of complaints on the net about the WPF richtext box not being compatible to the non-WPF one and from what I read I think I remember that this was considered a bug to be fixed. However I am not sure how this discussion went and if there might be a fix available. Maybe we are even not talking about the same issue, because you are saying that your richText boxes are showing the DOORS content correctly? My problem was, that the WPF box did not even show the content correctly. My luck was, that I did not even need to go into the 'edit' problem (I only needed to display the information). To do what you describe with the Winforms will be no fun, although possible with a lot of effort... The WinForms has functions for measuring the richText parts, so you could go with trying to put your Winforms comboboxes at the right position, but this would be probably just as bad as having to write your own richtext editor. So if the WPF RTB is showing the stuff alright now, the other thing you could try is dissect the richText to reformat any OLE objects so that they are compatible to DOORS again. Maybe you can work with the 'removeUnlistedRichText' function to make the generated RTF more compatible before writing it to DOORS. Or maybe you find something like an RTF 1.x to RTF 1.0 downgrade library that will create more compatible richtext for DOORS. From what I see DOORS could ignore the OLE because of the {\*\shppict ... } tag. Did you try to manually remove it and see if the OLE object reappears? Regards, Mathias Hi Mathias, thank you again :)
First of all, I was thinking about the idea of isolating the OLE objects (with markers or sth like that) in DXL, and then just deal with richTextNoOle() in my app, so that I will re-set every OLE object again via DXL when coming back to DOORS. But I think I could be so close that I want this idea to be the last alternative. About the removeUnlistedRichText function, I didn't know it, but does not work :( What about downgrading from the current (1.9) RTF specification to the DOORS one? I've googled a little, and I didn't find any parser or whatever, seems like nobody needed it. Does it really exist? Finally, I've checked that the {...shhpic...} node is not the conflictive one :( Furthermore, I've been trying to remove different parts of the output RTF (comparing input/output), but I cannot find it. Here it's the result for a RTF image (input from doors, and output after being set in my rtf control). The original one:
The output one:
|
Re: RTF OLE image not displayed Borja López - Fri Dec 13 10:22:55 EST 2013 Hi Mathias, thank you again :)
First of all, I was thinking about the idea of isolating the OLE objects (with markers or sth like that) in DXL, and then just deal with richTextNoOle() in my app, so that I will re-set every OLE object again via DXL when coming back to DOORS. But I think I could be so close that I want this idea to be the last alternative. About the removeUnlistedRichText function, I didn't know it, but does not work :( What about downgrading from the current (1.9) RTF specification to the DOORS one? I've googled a little, and I didn't find any parser or whatever, seems like nobody needed it. Does it really exist? Finally, I've checked that the {...shhpic...} node is not the conflictive one :( Furthermore, I've been trying to remove different parts of the output RTF (comparing input/output), but I cannot find it. Here it's the result for a RTF image (input from doors, and output after being set in my rtf control). The original one:
The output one:
Can you please post the complete richText of a (small) OLE object produced by your WPF richtext box and the original one of DOORS as a zipped attachment? I am pretty sure I can find out what DOORS does not like about the WPF version. Regards, Mathias |
Re: RTF OLE image not displayed Mathias Mamsch - Fri Dec 13 19:43:48 EST 2013 Can you please post the complete richText of a (small) OLE object produced by your WPF richtext box and the original one of DOORS as a zipped attachment? I am pretty sure I can find out what DOORS does not like about the WPF version. Regards, Mathias Yes, of course! I attach two TXTs, one with the original RTF, and the other one with the results after putting the RTF in the control, and getting it again (no modifications inside). Regards, Borja. Attachments Original DOORS RTF.txt Modified RichTextBox RTF.txt |
Re: RTF OLE image not displayed Borja López - Mon Dec 16 03:31:51 EST 2013 Yes, of course! I attach two TXTs, one with the original RTF, and the other one with the results after putting the RTF in the control, and getting it again (no modifications inside). Regards, Borja. I just noticed that you converted the metafile image in the RTF into PNG format. DOORS does only support WMF (Windows Meta Files) format for pictures. Did you convert to PNG on purpose or is that some default behaviour of the RichTextBox? Regards, Mathias |
Re: RTF OLE image not displayed Mathias Mamsch - Mon Dec 16 16:50:10 EST 2013 I just noticed that you converted the metafile image in the RTF into PNG format. DOORS does only support WMF (Windows Meta Files) format for pictures. Did you convert to PNG on purpose or is that some default behaviour of the RichTextBox? Regards, Mathias That was the default behaviour of the RTB, I just took the richTextWithOle(o."Object Text") string, and set it to the RTB the following way:
C# Code: TextRange myTextRange = new TextRange(this.Document.ContentStart, this.Document.ContentEnd); MemoryStream ms = [create MemoryStream from string] myTextRange.Load(ms, DataFormats.Rtf);
Then, to get the RTF content again to put it back to Doors (not edited): C# Code: TextRange myTextRange = new TextRange(this.Document.ContentStart, this.Document.ContentEnd); MemoryStream ms = new MemoryStream(); myTextRange.Save(ms, DataFormats.Rtf); textAsRtf = ASCIIEncoding.Default.GetString(ms.ToArray()); Regards, Borja. |
Re: RTF OLE image not displayed Borja López - Tue Dec 17 03:54:46 EST 2013 That was the default behaviour of the RTB, I just took the richTextWithOle(o."Object Text") string, and set it to the RTB the following way:
C# Code: TextRange myTextRange = new TextRange(this.Document.ContentStart, this.Document.ContentEnd); MemoryStream ms = [create MemoryStream from string] myTextRange.Load(ms, DataFormats.Rtf);
Then, to get the RTF content again to put it back to Doors (not edited): C# Code: TextRange myTextRange = new TextRange(this.Document.ContentStart, this.Document.ContentEnd); MemoryStream ms = new MemoryStream(); myTextRange.Save(ms, DataFormats.Rtf); textAsRtf = ASCIIEncoding.Default.GetString(ms.ToArray()); Regards, Borja. Well so you got two problems:
a) You need to make sure that the RTF that you get back contains WMF files (so the OLEs must not be converted to PNG) When I do:
string s = "{\\rtf1\\ansi\\ansicpg1252\\uc1\\htmautsp\\deff2{\\fonttbl{\\f0\\fcharset0 Times New Roman;}{\\f2\\fcharset0 Segoe UI;}{\\f3\\fcharset0 Tahoma;}}{\\colortbl\\red0\\green0\\blue0;\\red255\\green255\\blue255;\\red109\\green109\\blue109;}\\loch\\hich\\dbch\\pard\\plain\\ltrpar\\itap0{\\lang1033\\fs20\\f3\\cf2 \\cf2\\ql{\\f3 {\\lang3082\\highlight1\\ltrch Text with an OLE object.}\\li0\\ri0\\sa0\\sb0\\fi0\\ql\\par}
{\\f3 {\\highlight1\\ltrch }\\li0\\ri0\\sa0\\sb0\\fi0\\ql\\par}
{\\f3 {\\highlight1\\ltrch }{\\ltrch {\\pict\\wmetafile8\\picw1058\\pich2143\\picwgoal600\\pichgoal1215
0100090000034d07000001002106000000000400000003010800050000000b0200000000050000
... that is your original meta file embedded in the new richtext with shape pict removed ...
4066e2040000002d010000050000002e01060000000b000000320a240014000000040000000000
28005100050000002e01010000001400000026060f001e00433a5c57696e646f77735c73797377
6f7736345c6f6c6533322e646c6c000600000026060f0002003000030000000000
}}\\li0\\ri0\\sa0\\sb0\\fi0\\ql\\par}
}
}"
(current Object)."Object Text" = richText s
Then I get a picture in DOORS. From a quick search I could not find a fast solution to your WPF problem, so I guess you need to research on your own. But at least the goal is set now ;-) Hope this helps. Regards, Mathias |
Re: RTF OLE image not displayed Mathias Mamsch - Tue Dec 17 04:25:52 EST 2013 Well so you got two problems:
a) You need to make sure that the RTF that you get back contains WMF files (so the OLEs must not be converted to PNG) When I do:
string s = "{\\rtf1\\ansi\\ansicpg1252\\uc1\\htmautsp\\deff2{\\fonttbl{\\f0\\fcharset0 Times New Roman;}{\\f2\\fcharset0 Segoe UI;}{\\f3\\fcharset0 Tahoma;}}{\\colortbl\\red0\\green0\\blue0;\\red255\\green255\\blue255;\\red109\\green109\\blue109;}\\loch\\hich\\dbch\\pard\\plain\\ltrpar\\itap0{\\lang1033\\fs20\\f3\\cf2 \\cf2\\ql{\\f3 {\\lang3082\\highlight1\\ltrch Text with an OLE object.}\\li0\\ri0\\sa0\\sb0\\fi0\\ql\\par}
{\\f3 {\\highlight1\\ltrch }\\li0\\ri0\\sa0\\sb0\\fi0\\ql\\par}
{\\f3 {\\highlight1\\ltrch }{\\ltrch {\\pict\\wmetafile8\\picw1058\\pich2143\\picwgoal600\\pichgoal1215
0100090000034d07000001002106000000000400000003010800050000000b0200000000050000
... that is your original meta file embedded in the new richtext with shape pict removed ...
4066e2040000002d010000050000002e01060000000b000000320a240014000000040000000000
28005100050000002e01010000001400000026060f001e00433a5c57696e646f77735c73797377
6f7736345c6f6c6533322e646c6c000600000026060f0002003000030000000000
}}\\li0\\ri0\\sa0\\sb0\\fi0\\ql\\par}
}
}"
(current Object)."Object Text" = richText s
Then I get a picture in DOORS. From a quick search I could not find a fast solution to your WPF problem, so I guess you need to research on your own. But at least the goal is set now ;-) Hope this helps. Regards, Mathias Now with your explanation I can understand what is happening and it's more clear for me. I will carry on trying to solve this issue. Thank you very much for your effort :) Regards, Borja. |
Re: RTF OLE image not displayed Borja López - Tue Dec 17 04:34:22 EST 2013 Now with your explanation I can understand what is happening and it's more clear for me. I will carry on trying to solve this issue. Thank you very much for your effort :) Regards, Borja. Regarding to this issue again, finally I decided to replace each OLE by a string (following your useful example https://www.ibm.com/developerworks/community/forums/html/topic?id=4725bcb5-ac1a-4ddc-85b2-77835afcef9e&ps=10).
I've been searching about it, but I could not find anything. Is it possible to take a unique identifier for each OLE object? In this case, that algorithm is replacing the OLE Content {\pict\....} by {XXX}, but I'm looking forward to extract something from the OLE content, and put it where the XXX is.
Kind regards, Borja. |
Re: RTF OLE image not displayed Borja López - Tue Dec 24 06:05:40 EST 2013 Regarding to this issue again, finally I decided to replace each OLE by a string (following your useful example https://www.ibm.com/developerworks/community/forums/html/topic?id=4725bcb5-ac1a-4ddc-85b2-77835afcef9e&ps=10).
I've been searching about it, but I could not find anything. Is it possible to take a unique identifier for each OLE object? In this case, that algorithm is replacing the OLE Content {\pict\....} by {XXX}, but I'm looking forward to extract something from the OLE content, and put it where the XXX is.
Kind regards, Borja. Cant you generate a unique identifier for the OLE object from things like the database identifier, module identifier, absolute number of the object, attribute name and index of the OLE object inside the attribute value? Or do you want to generate a unique identifier from the content? That might be harder. Regards, Mathias |